package com.tau.egonetwork.linkedin;

import org.json.JSONObject;

import com.tau.egonetwork.net.AccessToken;
import com.tau.egonetwork.net.IResponse;

public class LinkedinAuthResponse implements IResponse {

	private final static String FIELD_ACCESS_TOKEN = "access_token";
	private final static String FIELD_EXPIRES = "expires_in";
	
	@Override
	public AccessToken parseJSONResponse(String response) {
		
		JSONObject json = new JSONObject(response);
		
		String access_token = json.getString(FIELD_ACCESS_TOKEN);
		long expires = json.getLong(FIELD_EXPIRES);
		
		AccessToken token = new AccessToken(access_token, expires);
		
		return token;
	}

}
